package com.bitcat.firstapp.demo.component

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bitcat.firstapp.R
import com.bitcat.firstapp.databinding.ActivityRadioButtonDemoBinding

class RadioButtonDemoActivity : AppCompatActivity() {

    private val binding: ActivityRadioButtonDemoBinding by lazy {
        ActivityRadioButtonDemoBinding.inflate(layoutInflater)
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(20, systemBars.top,20, systemBars.bottom)
            insets
        }

        binding.languageRadioGroup.setOnCheckedChangeListener { group, checkedId ->
            val checkItem = when(checkedId){
                R.id.kotlinRadioButton -> "Kotlin"
                R.id.javaRadioButton -> "Java"
                R.id.pythonRadioButton  -> "Python"
                R.id.javaScriptButton  -> "JavaScript"
                else -> "Unknown"
            }
            binding.resultTextView.text = "Selected Language: $checkItem"
        }
    }
}